<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <script src="../plugins/echarts/echarts.js"></script>
    <!-- 引入组件库 -->
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script src="../js/vue.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <style>
        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }

        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }

        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 178px;
            height: 178px;
            line-height: 178px;
            text-align: center;
        }

        .avatar {
            width: 178px;
            height: 178px;
            display: block;
        }

        .datatable {
            position: relative;
            box-sizing: border-box;
            -webkit-box-flex: 1;
            width: 100%;
            max-width: 100%;
            font-size: 14px;
            color: rgb(96, 98, 102);
            overflow: hidden;
            flex: 1 1 0%;
        }

        .datatable td, .datatable th {
            padding: 12px 0;
            min-width: 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            text-overflow: ellipsis;
            vertical-align: middle;
            position: relative;
            text-align: left;
        }
    </style>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>统计分析
            <small>后管数据统计(一)</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>后管数据统计(一)</el-breadcrumb-item>
        </el-breadcrumb>
        <span class="demonstration">日期查询</span>
        <el-date-picker
                v-model="startToEndDay"
                type="daterange"
                align="right"
                unlink-panels
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :picker-options="pickerOptions">
        </el-date-picker>
        <el-button @click="findByDate()" class="dalfBut" type="primary" round>查询</el-button>
    </div>
    <div class="app-container">
        <div class="box">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div id="chart1" style="height:500px;"><h1>请选择您要查询的日期范围</h1></div>
        </div>
    </div>
</div>

</body>
<script type="text/javascript">

    var vue = new Vue({
        el: '#app',
        data() {
            return {
                pickerOptions: {
                    shortcuts: [{
                        text: '最近一周',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近一个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近三个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit('pick', [start, end]);
                        }
                    }]
                },
                startToEndDay: ''
            };
        },
        created() {
        },
        methods: {
            findByDate() {
                console.log("查询起始日期" + this.startToEndDay[0])
                console.log("查询结束日期" + this.startToEndDay[1])

                // 基于准备好的dom，初始化echarts实例
                var myChart1 = echarts.init(document.getElementById('chart1'));

                axios.post("/report/getOrderReportByDate.do", this.startToEndDay).then((res) => {
                    myChart1.setOption(
                        {
                            title: {
                                text: '后管数据统计(一)',
                            },
                            tooltip: {
                                trigger: 'axis'
                            },
                            legend: {
                                data: ['每日预约数', '每日到诊数']
                            },
                            toolbox: {
                                show: true,
                                feature: {
                                    dataZoom: {
                                        yAxisIndex: 'none'
                                    },
                                    dataView: {readOnly: false},
                                    magicType: {type: ['line', 'bar']},
                                    restore: {},
                                    saveAsImage: {}
                                }
                            },
                            xAxis: {
                                type: 'category',
                                boundaryGap: false,
                                // data: ['2019.04.28', '2019.09.18', '2019.10.31', '2019.11.01', '2019.11.05', '2019.11.14', '2021.07.07', '2021.07.14', '2021.07.16']
                                data: res.data.data.dateRange
                            },
                            yAxis: {
                                axisLine: {show: true},
                                axisTick: {show: true},
                                type: 'value',
                                axisLabel: {
                                    formatter: '{value}'
                                }
                            },
                            series: [
                                {
                                    name: '每日预约数',
                                    type: 'line',
                                    // data: [1, 1, 2, 1, 1, 1, 2, 1, 1],
                                    data: res.data.data.countOrder

                                },
                                {
                                    name: '每日到诊数',
                                    type: 'line',
                                    // data: [0, 0, 1, 0, 1, 1, 1, 0, 0],
                                    data: res.data.data.haveDatedCount
                                }
                            ]
                        });
                });
            }
        }
    });

    //默认值页面
    // 基于准备好的dom，初始化echarts实例
    var myChart1 = echarts.init(document.getElementById('chart1'));

    myChart1.setOption(
        {
            title: {
                text: '后管数据统计(一)',
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data: ['每日预约数', '每日到诊数']
            },
            toolbox: {
                show: true,
                feature: {
                    dataZoom: {
                        yAxisIndex: 'none'
                    },
                    dataView: {readOnly: false},
                    magicType: {type: ['line', 'bar']},
                    restore: {},
                    saveAsImage: {}
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: ['2019.04.28', '2019.09.18', '2019.10.31', '2019.11.01', '2019.11.05', '2019.11.14', '2021.07.07', '2021.07.14', '2021.07.16']
            },
            yAxis: {
                axisLine: {show: true},
                axisTick: {show: true},
                type: 'value',
                axisLabel: {
                    formatter: '{value}'
                }
            },
            series: [
                {
                    name: '每日预约数',
                    type: 'line',
                    data: [1, 1, 2, 1, 1, 1, 2, 1, 1]
                },
                {
                    name: '每日到诊数',
                    type: 'line',
                    data: [0, 0, 1, 0, 1, 1, 1, 0, 0]
                }
            ]
        });
</script>
</html>
